function randomString(len) {
	len = len || 32;
	var $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678';
	var maxPos = $chars.length;
	var pwd = '';
	for (i = 0; i < len; i++) {
		pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
	}
	return pwd;
}
function wxshare(sharetitle,sharedesc,shareimgurl){
	var sharelink=location.href.split('#')[0];
	var shareparams={
		durl:location.href.split('#')[0],
		appid:'wx1bfc16aced66417f',
		nonceStr:randomString(32),
  		timestamp:parseInt(Number(new Date())/1000)
	}
	$.ajax({
		method:'get',
		url:'http://djwwpt.dangjian.com/wxshare/jssdk.php',
		dataType:"text",
		data:shareparams,
		success(data){
			//console.log(data,'分享成功')	;
			var params = JSON.parse(data);
			//console.log(params,'数据',shareparams);	
			wx.config({
			  debug: false,
			  appId: shareparams.appid,//'wx1bfc16aced66417f'// 必填，公众号的唯一标识
			  timestamp:shareparams.timestamp,
			  nonceStr:shareparams.nonceStr,
			  signature: params.signature,// 必填，签名
			  jsApiList: ['updateAppMessageShareData','updateTimelineShareData'] // 必填，需要使用的JS接口列表
			});
			wx.ready(function () {   //需在用户可能点击分享按钮前就先调用
			  wx.updateAppMessageShareData({ 
			    title: sharetitle, // 分享标题
			    desc: sharedesc, // 分享描述
			    link: sharelink, 
			    imgUrl: shareimgurl,
			    success: function (res) {
			      //alert(res,'分享成功')
			    }
			  })

			  wx.updateTimelineShareData({ 
			    title: sharetitle, // 分享标题
			    desc: sharedesc, // 分享描述
			    link: sharelink, 
			    imgUrl: shareimgurl,
			    success: function (res) {
			      //alert(res,'分享成功')
			    }
			  })

				wx.error(function(res){
					console(res,'分享出错')
				});
			}); 	
		},error(msg){
			console.log(msg,'error');
		}
	})
}